package com.zlll.winner.service.advertising;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zlll.winner.business.model.advertising.AdvertisingSpace;
import com.zlll.winner.mapper.advertising.AdvertisingSpaceMapper;
import com.zlll.winner.business.service.advertising.IAdvertisingSpaceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 广告位置表 服务实现类
 * </p>
 *
 * @author qsx
 * @since 2019-09-07
 */
@Service
public class AdvertisingSpaceServiceImpl extends ServiceImpl<AdvertisingSpaceMapper, AdvertisingSpace> implements IAdvertisingSpaceService {

    @Autowired
    private AdvertisingSpaceMapper advertisingSpaceMapper;

    @Override
    public List<AdvertisingSpace> getAdvertisingSpace(Integer type, Integer category) {
        LambdaQueryWrapper<AdvertisingSpace> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(AdvertisingSpace::getType, type);
        wrapper.eq(AdvertisingSpace::getCategory, category);
        wrapper.eq(AdvertisingSpace::getIsDel,0);
        return list(wrapper);
    }

    /**
     * 获取广告位信息
     * @param type
     * @return
     */
    @Override
    @Transactional(readOnly = true, rollbackFor = Exception.class)
    public List getSpaceByTypeAndCategory(Integer type, Integer category) {
        return advertisingSpaceMapper.getSpaceByTypeAndCategory(type, category);
    }
}
